﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.Framework.Data;
using Com.Framework;

namespace Com.Library.DB.Board
{
	public class BoardModel
	{
		private BoardModel()
		{
		}

		public static void Create(byte BoardSN, string BoardName, string JsonData)
		{
			BoardCreate access = new BoardCreate();
			
			BoardCreateArguments args = new BoardCreateArguments()
			{
				n1BoardSN = BoardSN,
				strBoardName = BoardName,
				strJsonData = JsonData
			};

			access.SetArguments(args);
			access.ExecuteNonQuery();
		}

		public static List<BoardEntity> GetList(int PageNo, byte PageSize, out int CntTotal)
		{
			BoardGetList access = new BoardGetList();

			BoardGetListArguments args = new BoardGetListArguments()
			{
				PageNo = PageNo,
				PageSize = PageSize
			};

			access.SetArguments(args);
			List<BoardEntity> list = access.Execute();
			DataEntity output = access.GetOutput();

			CntTotal = output.GetData2("CntTotal", 0);

			return list;
		}

		public static void Modify(byte BoardSN, string BoardName, string JsonData)
		{
			BoardModify access = new BoardModify();

			BoardModifyArguments args = new BoardModifyArguments()
			{
				n1BoardSN = BoardSN,
				strBoardName = BoardName,
				strJsonData = JsonData
			};

			access.SetArguments(args);
			access.ExecuteNonQuery();
		}

		public static void Remove(byte BoardSN)
		{
			BoardRemove access = new BoardRemove();

			BoardRemoveArguments args = new BoardRemoveArguments()
			{
				n1BoardSN = BoardSN
			};

			access.SetArguments(args);
			access.ExecuteNonQuery();
		}
	}
}
